﻿using HarmonyLib;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;

namespace SZ.Mech
{



    [HarmonyPatch(typeof(Thing), nameof(Thing.TakeDamage))]
    public static class Thing_Patch
    {
        //public static void Postfix(ref Thing __instance, ref DamageWorker.DamageResult __result, DamageInfo dinfo)
        //{
        //    if (__instance is Pawn)
        //    {
        //        bool hasGnomon = (__instance as Pawn).health.hediffSet.HasHediff(SZ_DefOf.SZ_Gnomon);

        //        if (hasGnomon && (dinfo.Def == SZ_DefOf.SZ_Thunder || dinfo.Def == SZ_DefOf.SZ_ThunderSec))
        //        {
        //            __result = new DamageWorker.DamageResult();
        //        }
        //    }
        //}

        /// <summary>
        /// 前缀，让具有该hediff的单位跳过雷击伤害
        /// </summary>
        /// <param name="__instance"></param>
        //public static bool Prefix(ref Thing __instance, ref DamageWorker.DamageResult __result,ref DamageInfo dinfo)
        //{
        //    if (__instance is Pawn)
        //    {
        //        bool hasGnomon = (__instance as Pawn).health.hediffSet.HasHediff(SZ_DefOf.SZ_Gnomon);

        //        if (hasGnomon && (dinfo.Def == SZ_DefOf.SZ_Thunder || dinfo.Def == SZ_DefOf.SZ_ThunderSec))
        //        {
        //            dinfo = new DamageInfo(dinfo.Def,0);
        //        }
        //    }
        //    return false;
        //}
        ///// <summary>
        ///// 前缀，让具有该hediff的单位跳过雷击伤害
        ///// </summary>
        ///// <param name="__instance"></param>
        //public static bool Prefix(ref Thing __instance, ref DamageWorker.DamageResult __result, DamageInfo dinfo)
        //{
        //    if (__instance is Pawn)
        //    {
        //        bool hasGnomon = (__instance as Pawn).health.hediffSet.HasHediff(SZ_DefOf.SZ_Gnomon);

        //        if (hasGnomon && (dinfo.Def == SZ_DefOf.SZ_Thunder || dinfo.Def == SZ_DefOf.SZ_ThunderSec))
        //        {

        //            __result = new DamageWorker.DamageResult();
        //            return true;
        //        }
        //    }
        //    return false;
        //}
    }
}
